package com.softserve;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.TextView;

/**
 * Created by IntelliJ IDEA.
 * User: override
 * Date: 5/29/11
 * Time: 12:03 PM
 * To change this template use File | Settings | File Templates.
 */
public class RegActivity extends Activity {

    private TextView name, surname, patronymic, ticketNumber, voyage, ticketClass, passport;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.reglist);

        Integer pos = (Integer) getIntent().getExtras().get("selectionPosition");

        name = (TextView) findViewById(R.id.name);
        surname = (TextView) findViewById(R.id.surname);
        patronymic = (TextView) findViewById(R.id.patronymic);
        ticketClass = (TextView) findViewById(R.id.ticketClass);
        voyage = (TextView) findViewById(R.id.voyage);
        ticketNumber = (TextView) findViewById(R.id.ticketNumber);
        passport = (TextView) findViewById(R.id.passport);

        name.setText(PersonsList.getPersonList().get(pos).getName());
        surname.setText(PersonsList.getPersonList().get(pos).getSurname());
        patronymic.setText(PersonsList.getPersonList().get(pos).getPatronymic());
        ticketClass.setText(PersonsList.getPersonList().get(pos).getTicketClass());
        voyage.setText(PersonsList.getPersonList().get(pos).getVoyage());
        ticketNumber.setText(PersonsList.getPersonList().get(pos).getTicketNumber());
        passport.setText(PersonsList.getPersonList().get(pos).getPassport());
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
            case R.id.back:
                backMenu();
                return true;
            case R.id.registration:
                registrationMenu();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    public void backMenu() {
        Intent i = new Intent(RegActivity.this, MainActivity.class);
        startActivity(i);
    }

    public void registrationMenu() {
        Intent i = new Intent(RegActivity.this, MainActivity.class);
        startActivity(i);
    }
}
